from django.db import models



class DataLogs(models.Model):
    data_uid = models.CharField(max_length=64, verbose_name='操作的数据编码')
    operation = models.CharField(choices=(('0', '插入'), ('1', '修改'), ('2', '删除')), max_length=16, verbose_name='操作')
    # 通过接口还是通过后台修改
    method = models.CharField(choices=((0, '接口'), (1, '后台')), max_length=16, verbose_name='数据修改方式')
    # 是对历史对话库的修改还是知识库的修改
    database = models.CharField(choices=((0, '历史对话库'), (0, '知识库')), max_length=16, verbose_name='修改数据库')
    content = models.JSONField(max_length=256,  verbose_name='数据字段内容', default={"info": ""})
    user = models.CharField(max_length=64, verbose_name='添加用户', blank=True, null=True)
    status = models.BooleanField(choices=((1, '有效'), (0, '无效')), verbose_name='状态', default=1)
    comment = models.CharField(max_length=256, verbose_name='备注', blank=True, null=True)
    create_time = models.DateTimeField(auto_now_add=True, null=False, blank=False, verbose_name='创建时间')

    def __str__(self):
        return self.code

    class Meta:
        verbose_name = "mysql日志表"
        verbose_name_plural = verbose_name